From b92291742495b263e42ae43a6c7758074806a71c Mon Sep 17 00:00:00 2001 From: "Matteo F. Vescovi" Date: Sat, 18 Feb 2017 14:16:36 +0100 Subject: [PATCH] New upstream version 0.1.24 --- AUTHORS | 3 + INSTALL | 10 +- Makefile.in | 2 +- NEWS | 6 + README | 14 +- babl/babl-cache.c | 44 +++- babl/babl-fish-path.c | 26 ++- babl/babl-fish.c | 2 + babl/babl-hash-table.c | 14 +- babl/babl-version.h | 2 +- babl/base/pow-24.h | 27 ++- babl/base/util.h | 3 + config.guess | 28 ++- config.sub | 22 +- configure | 32 +-- configure.ac | 4 +- docs/index-static.html.in | 2 +- extensions/16bit.c | 103 +++++++++ extensions/CIE.c | 83 ++++++-- extensions/Makefile.am | 1 + extensions/Makefile.in | 22 +- extensions/cairo.c | 224 +++++++++++++++++++- extensions/fast-float.c | 52 ++++- extensions/gggl-lies.c | 38 +++- extensions/gggl.c | 24 +++ extensions/gimp-8bit.c | 20 ++ extensions/simple.c | 429 ++++++++++++++++++++++++++++++++++++-- extensions/sse2-float.c | 16 +- extensions/sse2-int8.c | 41 ++++ tools/babl-verify.c | 37 +++- 30 files changed, 1207 insertions(+), 124 deletions(-) create mode 100644 extensions/16bit.c diff --git a/AUTHORS b/AUTHORS index ae2fec2..01b5dbf 100644 --- a/AUTHORS +++ b/AUTHORS @@ -52,6 +52,9 @@
Micheal Muré
portability fixes
+
Edward E
+
win32 platform adaptations
+
Maxime Nicco
HSV color model extension
Teo Mazars
diff --git a/INSTALL b/INSTALL index c937773..6ec1490 100644 --- a/INSTALL +++ b/INSTALL @@ -1,5 +1,5 @@ -babl 0.1.22 +babl 0.1.24 Dynamic; any to any, pixel format conversion library. @@ -12,10 +12,10 @@ From a released version the following is the expected method of installation (or a variation on this theme): ------------------------------------------------------------ - foo$ wget ftp://ftp.gtk.org/pub/babl/0.1/babl-0.1.22.tar.bz2 - foo$ tar jxf babl-0.1.22.tar.gz - foo$ cd babl-0.1.22 - foo/babl-0.1.22$ ./configure && make && sudo make install + foo$ wget ftp://ftp.gtk.org/pub/babl/0.1/babl-0.1.24.tar.bz2 + foo$ tar jxf babl-0.1.24.tar.gz + foo$ cd babl-0.1.24 + foo/babl-0.1.24$ ./configure && make && sudo make install ------------------------------------------------------------ diff --git a/Makefile.in b/Makefile.in index 98b34ed..86bde56 100644 --- a/Makefile.in +++ b/Makefile.in @@ -195,7 +195,7 @@ DIST_SUBDIRS = babl extensions tests tools docs am__DIST_COMMON = $(srcdir)/INSTALL.in $(srcdir)/Makefile.in \ $(srcdir)/babl.pc.in $(srcdir)/config.h.in AUTHORS COPYING \ INSTALL NEWS README TODO compile config.guess config.sub \ - depcomp install-sh ltmain.sh missing + install-sh ltmain.sh missing DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) diff --git a/NEWS b/NEWS index a885050..4cf2b21 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,12 @@ the news section both in the README and the webpage. --> + +2017-02-01 babl-0.1.24
+Improvements to profile cache persistance, fast paths that improve actual GIMP +use on various precisions, use single precision constants for some more of CIE +computions. +
2016-11-05 babl-0.1.22
Added cache of profiled conversions, added HCY color model, some precision and performance updated for fast paths. diff --git a/README b/README index dd22fe7..38f10d1 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -Babl-0.1.22 +Babl-0.1.24 Contents @@ -46,8 +46,8 @@ pixel formats. Download -The latest versioned development version of babl can be found in ftp:// -ftp.gtk.org/pub/babl/. +The latest versioned development version of babl can be found in https: +//download.gimp.org/pub/babl/. Babl uses git. The main repository is hosted by GNOME. It can be browsed online and cloned with: @@ -59,6 +59,10 @@ babl release. If there are significant improvements to babl when a GEGL release is done a babl release is most often put out just prior to the GEGL release. +2017-02-01 babl-0.1.24 + Improvements to profile cache persistance, fast paths that improve + actual GIMP use on various precisions, use single precision + constants for some more of CIE computions. 2016-11-05 babl-0.1.22 Added cache of profiled conversions, added HCY color model, some precision and performance updated for fast paths. @@ -2048,6 +2052,8 @@ Simon Budig cleanups Micheal Muré portability fixes +Edward E + win32 platform adaptations Maxime Nicco HSV color model extension @@ -2069,4 +2075,4 @@ Jon Nordby Massimo Valentini stability fixes -/babl-0.1.22 +/babl-0.1.24 diff --git a/babl/babl-cache.c b/babl/babl-cache.c index 1f0b6f5..5f7b716 100644 --- a/babl/babl-cache.c +++ b/babl/babl-cache.c @@ -16,6 +16,10 @@ * . */ +#ifdef _WIN32 +#include +#endif + #include #include #include "config.h" @@ -51,7 +55,7 @@ mk_ancestry_iter (const char *path) } } } - return -1; + return 0; } static int @@ -77,8 +81,13 @@ static const char *fish_cache_path (void) if (getenv ("HOME")) sprintf (path, "%s/.cache/babl/babl-fishes", getenv("HOME")); #else - if (getenv ("TEMP")) +{ + char win32path[4096]; + if (SHGetFolderPathA (NULL, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, win32path) == S_OK) + sprintf (path, "%s\\%s\\babl-fishes.txt", win32path, BABL_LIBRARY); + else if (getenv ("TEMP")) sprintf (path, "%s\\babl-fishes.txt", getenv("TEMP")); +} #endif if (stat (path, &stat_buf)==0 && S_ISREG(stat_buf.st_mode)) @@ -135,15 +144,32 @@ static int compare_fish_pixels (const void *a, const void *b) ((*fb)->fish.processings - (*fa)->fish.processings); } +static const char *cache_header (void) +{ + static char buf[2048]; + if (strchr (BABL_GIT_VERSION, ' ')) // we must be building from tarball + sprintf (buf, "#%i.%i.%i BABL_PATH_LENGTH=%d BABL_TOLERANCE=%f", + BABL_MAJOR_VERSION, BABL_MINOR_VERSION, BABL_MICRO_VERSION, + _babl_max_path_len (), _babl_legal_error ()); + else + sprintf (buf, "#%s BABL_PATH_LENGTH=%d BABL_TOLERANCE=%f", + BABL_GIT_VERSION, + _babl_max_path_len (), _babl_legal_error ()); + return buf; +} + void babl_store_db (void) { BablDb *db = babl_fish_db (); int i; - FILE *dbfile = fopen (fish_cache_path (), "w"); + char *tmpp = calloc(8000,1); + FILE *dbfile; + + sprintf (tmpp, "%s~", fish_cache_path ()); + dbfile = fopen (tmpp, "w"); if (!dbfile) return; - fprintf (dbfile, "#%s BABL_PATH_LENGTH=%d BABL_TOLERANCE=%f\n", - BABL_GIT_VERSION, _babl_max_path_len (), _babl_legal_error ()); + fprintf (dbfile, "%s\n", cache_header ()); /* sort the list of fishes by usage, making next run more efficient - * and the data easier to approach as data for targeted optimization @@ -159,6 +185,9 @@ void babl_store_db (void) fprintf (dbfile, "%s----\n", tmp); } fclose (dbfile); + + rename (tmpp, fish_cache_path()); + free (tmpp); } static int @@ -254,10 +283,7 @@ void babl_init_db (void) case '#': /* if babl has changed in git .. drop whole cache */ { - char buf[2048]; - sprintf (buf, "#%s BABL_PATH_LENGTH=%d BABL_TOLERANCE=%f", - BABL_GIT_VERSION, _babl_max_path_len (), _babl_legal_error ()); - if (strcmp ( token, buf)) + if (strcmp ( token, cache_header ())) { free (contents); return; diff --git a/babl/babl-fish-path.c b/babl/babl-fish-path.c index 23e7757..4f169d0 100644 --- a/babl/babl-fish-path.c +++ b/babl/babl-fish-path.c @@ -21,7 +21,7 @@ #include "babl-internal.h" #include "babl-ref-pixels.h" -#define BABL_TOLERANCE 0.000006 +#define BABL_TOLERANCE 0.000001 #define BABL_MAX_COST_VALUE 2000000 #define BABL_HARD_MAX_PATH_LENGTH 8 #define BABL_MAX_NAME_LEN 1024 @@ -333,6 +333,11 @@ babl_fish_path (const Babl *source, get_conversion_path (&pc, (Babl *) source, 0, max_path_length ()); + /* second attempt,. at path length + 1*/ + if (babl->fish_path.conversion_list->count == 0 && + max_path_length () + 1 <= BABL_HARD_MAX_PATH_LENGTH) + get_conversion_path (&pc, (Babl *) source, 0, max_path_length () + 1); + babl_in_fish_path--; babl_free (pc.current_path); } @@ -341,6 +346,25 @@ babl_fish_path (const Babl *source, { babl_free (babl); babl_mutex_unlock (babl_format_mutex); + +#ifndef BABL_UNSTABLE + if (debug_conversions) +#endif + { + static int warnings = 0; + if (warnings++ == 0) + fprintf (stderr, +"Missing fast-path babl conversion detected, Implementing missing babl fast paths\n" +"accelerates GEGL, GIMP and other software using babl, warnings are printed on\n" +"first occurance of formats used where a conversion has to be synthesized\n" +"programmatically by babl based on format description\n" +"\n"); + + fprintf (stderr, "*WARNING*: missing babl fast path(s) between formats \"%s\" and \"%s\"\n", + babl_get_name (source), + babl_get_name (destination)); + + } return NULL; } diff --git a/babl/babl-fish.c b/babl/babl-fish.c index 76cb53d..96c69c3 100644 --- a/babl/babl-fish.c +++ b/babl/babl-fish.c @@ -133,6 +133,8 @@ babl_fish_get_id (const Babl *source, * source/destination values. */ ptrdiff_t id = source - destination; /* instances with id 0 won't be inserted into database */ + id *= ((((size_t) (source))) % 37); + if (id == 0) id = 1; return id; diff --git a/babl/babl-hash-table.c b/babl/babl-hash-table.c index d507cb2..e1c2e56 100644 --- a/babl/babl-hash-table.c +++ b/babl/babl-hash-table.c @@ -58,15 +58,11 @@ babl_hash_by_int (BablHashTable *htab, int id) { int hash = 0; - int i; - - for (i = 0; i < sizeof (int); i++) - { - hash += id & 0xFF; - hash += (hash << 10); - hash ^= (hash >> 6); - id >>= 8; - } + hash += id & 0xFF; + hash += (hash << 10); + hash ^= (hash >> 6); + id >>= 8; + hash += id & 0xFF; hash += (hash << 3); hash ^= (hash >> 11); hash += (hash << 15); diff --git a/babl/babl-version.h b/babl/babl-version.h index 11c7b8f..9adad13 100644 --- a/babl/babl-version.h +++ b/babl/babl-version.h @@ -34,7 +34,7 @@ #define BABL_MAJOR_VERSION 0 #define BABL_MINOR_VERSION 1 -#define BABL_MICRO_VERSION 22 +#define BABL_MICRO_VERSION 24 /** Get the version information on the babl library */ void babl_get_version (int *major, diff --git a/babl/base/pow-24.h b/babl/base/pow-24.h index cbd6fd4..5271b40 100644 --- a/babl/base/pow-24.h +++ b/babl/base/pow-24.h @@ -78,6 +78,31 @@ babl_pow_1_24 (double x) return x*y; } + +#include +/* frexpf copied from musl */ +static inline float babl_frexpf(float x, int *e) +{ + union { float f; uint32_t i; } y = { x }; + int ee = y.i>>23 & 0xff; + + if (!ee) { + if (x) { + x = babl_frexpf(x*0x1p64, e); + *e -= 64; + } else *e = 0; + return x; + } else if (ee == 0xff) { + return x; + } + + *e = ee - 0x7e; + y.i &= 0x807ffffful; + y.i |= 0x3f000000ul; + return y.f; +} + + ////////////////////////////////////////////// /* a^b = exp(b*log(a)) * @@ -96,7 +121,7 @@ static inline float init_newtonf (float x, float exponent, float c0, float c1, float c2) { int iexp; - float y = frexpf(x, &iexp); + float y = babl_frexpf(x, &iexp); y = 2*y+(iexp-2); c1 *= M_LN2*exponent; c2 *= M_LN2*M_LN2*exponent*exponent; diff --git a/babl/base/util.h b/babl/base/util.h index 3472523..2d346b4 100644 --- a/babl/base/util.h +++ b/babl/base/util.h @@ -105,4 +105,7 @@ babl_gamma_2_2_to_linearf (float value) #else #define linear_to_gamma_2_2(value) (pow((value), (1.0F/2.2F))) #define gamma_2_2_to_linear(value) (pow((value), 2.2F)) + + #define babl_linear_to_gamma_2_2f(value) (powf((value), (1.0f/2.2f))) + #define babl_gamma_2_2_to_linearf(value) (powf((value), 2.2f)) #endif diff --git a/config.guess b/config.guess index 0967f2a..2e9ad7f 100755 --- a/config.guess +++ b/config.guess @@ -2,7 +2,7 @@ # Attempt to guess a canonical system name. # Copyright 1992-2016 Free Software Foundation, Inc. -timestamp='2016-04-02' +timestamp='2016-10-02' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -186,9 +186,12 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched - # to ELF recently, or will in the future. + # to ELF recently (or will in the future) and ABI. case "${UNAME_MACHINE_ARCH}" in - arm*|earm*|i386|m68k|ns32k|sh3*|sparc|vax) + earm*) + os=netbsdelf + ;; + arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ @@ -997,6 +1000,9 @@ EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } ;; + mips64el:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; openrisc*:Linux:*:*) echo or1k-unknown-linux-${LIBC} exit ;; @@ -1029,6 +1035,9 @@ EOF ppcle:Linux:*:*) echo powerpcle-unknown-linux-${LIBC} exit ;; + riscv32:Linux:*:* | riscv64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux-${LIBC} exit ;; @@ -1408,18 +1417,17 @@ esac cat >&2 < in order to provide the needed -information to handle your system. +If $0 has already been updated, send the following data and any +information you think might be pertinent to config-patches@gnu.org to +provide the necessary information to handle your system. config.guess timestamp = $timestamp diff --git a/config.sub b/config.sub index 8d39c4b..dd2ca93 100755 --- a/config.sub +++ b/config.sub @@ -2,7 +2,7 @@ # Configuration validation subroutine script. # Copyright 1992-2016 Free Software Foundation, Inc. -timestamp='2016-03-30' +timestamp='2016-11-04' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -117,7 +117,7 @@ case $maybe_os in nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \ - kopensolaris*-gnu* | \ + kopensolaris*-gnu* | cloudabi*-eabi* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` @@ -301,6 +301,7 @@ case $basic_machine in | open8 | or1k | or1knd | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle \ + | pru \ | pyramid \ | riscv32 | riscv64 \ | rl78 | rx \ @@ -428,6 +429,7 @@ case $basic_machine in | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ + | pru-* \ | pyramid-* \ | riscv32-* | riscv64-* \ | rl78-* | romp-* | rs6000-* | rx-* \ @@ -643,6 +645,14 @@ case $basic_machine in basic_machine=m68k-bull os=-sysv3 ;; + e500v[12]) + basic_machine=powerpc-unknown + os=$os"spe" + ;; + e500v[12]-*) + basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + os=$os"spe" + ;; ebmon29k) basic_machine=a29k-amd os=-ebmon @@ -1022,7 +1032,7 @@ case $basic_machine in ppc-* | ppcbe-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; - ppcle | powerpclittle | ppc-le | powerpc-little) + ppcle | powerpclittle) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) @@ -1032,7 +1042,7 @@ case $basic_machine in ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; - ppc64le | powerpc64little | ppc64-le | powerpc64-little) + ppc64le | powerpc64little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) @@ -1389,7 +1399,7 @@ case $os in | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* | -cegcc* \ | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ + | -midipix* | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ | -linux-newlib* | -linux-musl* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ @@ -1399,7 +1409,7 @@ case $os in | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \ - | -onefs* | -tirtos*) + | -onefs* | -tirtos* | -phoenix* | -fuchsia*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) diff --git a/configure b/configure index 0931451..67c251e 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for babl 0.1.22. +# Generated by GNU Autoconf 2.69 for babl 0.1.24. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -587,8 +587,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='babl' PACKAGE_TARNAME='babl' -PACKAGE_VERSION='0.1.22' -PACKAGE_STRING='babl 0.1.22' +PACKAGE_VERSION='0.1.24' +PACKAGE_STRING='babl 0.1.24' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -1380,7 +1380,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures babl 0.1.22 to adapt to many kinds of systems. +\`configure' configures babl 0.1.24 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1452,7 +1452,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of babl 0.1.22:";; + short | recursive ) echo "Configuration of babl 0.1.24:";; esac cat <<\_ACEOF @@ -1572,7 +1572,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -babl configure 0.1.22 +babl configure 0.1.24 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1937,7 +1937,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by babl $as_me 0.1.22, which was +It was created by babl $as_me 0.1.24, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2293,11 +2293,11 @@ ac_config_headers="$ac_config_headers config.h" BABL_MAJOR_VERSION=0 BABL_MINOR_VERSION=1 -BABL_MICRO_VERSION=22 +BABL_MICRO_VERSION=24 BABL_INTERFACE_AGE=1 -BABL_BINARY_AGE=122 -BABL_VERSION=0.1.22 -BABL_REAL_VERSION=0.1.22 +BABL_BINARY_AGE=124 +BABL_VERSION=0.1.24 +BABL_REAL_VERSION=0.1.24 BABL_API_VERSION=0.1 @@ -2332,7 +2332,7 @@ fi -BABL_LIBRARY_VERSION="121:1:121" +BABL_LIBRARY_VERSION="123:1:123" BABL_CURRENT_MINUS_AGE=0 @@ -2964,7 +2964,7 @@ fi # Define the identity of the package. PACKAGE='babl' - VERSION='0.1.22' + VERSION='0.1.24' # Some tools Automake needs. @@ -13910,7 +13910,7 @@ $as_echo_n "checking whether we can compile half-floating point code... " >&6; } int main () { -__m128 val = _mm_cvtph_ps ((__m128i)_mm_setzero_ps()); +__m128 val = _mm_cvtph_ps ((__m128i)_mm_setzero_ps()); __m128i val2 = _mm_insert_epi64((__m128i)_mm_setzero_ps(), 0, 0); ; return 0; } @@ -14854,7 +14854,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by babl $as_me 0.1.22, which was +This file was extended by babl $as_me 0.1.24, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -14920,7 +14920,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -babl config.status 0.1.22 +babl config.status 0.1.24 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index 77f9b0c..c15f689 100644 --- a/configure.ac +++ b/configure.ac @@ -14,7 +14,7 @@ AC_PREREQ(2.54) m4_define([babl_major_version], [0]) m4_define([babl_minor_version], [1]) -m4_define([babl_micro_version], [22]) +m4_define([babl_micro_version], [24]) m4_define([babl_real_version], [babl_major_version.babl_minor_version.babl_micro_version]) m4_define([babl_version], [babl_real_version]) @@ -408,7 +408,7 @@ if test "x$enable_mmx" = xyes; then CFLAGS="$CFLAGS $sse_flag $f16c_flag" - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include ],[__m128 val = _mm_cvtph_ps ((__m128i)_mm_setzero_ps());])], + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include ],[__m128 val = _mm_cvtph_ps ((__m128i)_mm_setzero_ps()); __m128i val2 = _mm_insert_epi64((__m128i)_mm_setzero_ps(), 0, 0);])], AC_DEFINE(USE_F16C, 1, [Define to 1 if f16c intrinsics are available.]) AC_MSG_RESULT(yes) , diff --git a/docs/index-static.html.in b/docs/index-static.html.in index c71f236..64a1267 100644 --- a/docs/index-static.html.in +++ b/docs/index-static.html.in @@ -154,7 +154,7 @@

Download

The latest versioned development version of babl can be found in - ftp://ftp.gtk.org/pub/babl/. + https://download.gimp.org/pub/babl/.

Babl uses git. The main repository is hosted by GNOME. diff --git a/extensions/16bit.c b/extensions/16bit.c new file mode 100644 index 0000000..96701ef --- /dev/null +++ b/extensions/16bit.c @@ -0,0 +1,103 @@ +/* babl - dynamically extendable universal pixel conversion library. + * Copyright (C) 2016, Øyvind Kolås. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see + * . + */ + +#include "config.h" +#include +#include + +#include "babl.h" + +#include "base/util.h" +#include "extensions/util.h" + +static inline long +conv_rgbu16_rgbau16 (unsigned char *src, + unsigned char *dst, + long samples) + + +{ + uint16_t *src16 = (uint16_t*) src; + uint16_t *dst16 = (uint16_t*) dst; + long n = samples; + + while (n--) + { + *dst16++ = *src16++; + *dst16++ = *src16++; + *dst16++ = *src16++; + *dst16++ = 0xffff; + } + + return samples; +} + +static inline long +conv_yu16_yau16 (unsigned char *src, + unsigned char *dst, + long samples) + + +{ + uint16_t *src16 = (uint16_t*) src; + uint16_t *dst16 = (uint16_t*) dst; + long n = samples; + + while (n--) + { + *dst16++ = *src16++; + *dst16++ = 0xffff; + } + + return samples; +} + +int init (void); + +int +init (void) +{ + babl_conversion_new ( + babl_format ("R'G'B' u16"), + babl_format ("R'G'B'A u16"), + "linear", + conv_rgbu16_rgbau16, + NULL); + + babl_conversion_new ( + babl_format ("Y' u16"), + babl_format ("Y'A u16"), + "linear", + conv_yu16_yau16, + NULL); + + babl_conversion_new ( + babl_format ("RGB u16"), + babl_format ("RGBA u16"), + "linear", + conv_rgbu16_rgbau16, + NULL); + + babl_conversion_new ( + babl_format ("Y u16"), + babl_format ("YA u16"), + "linear", + conv_yu16_yau16, + NULL); + return 0; +} diff --git a/extensions/CIE.c b/extensions/CIE.c index 2e0aca2..e1e2fa7 100644 --- a/extensions/CIE.c +++ b/extensions/CIE.c @@ -28,8 +28,8 @@ #define DEGREES_PER_RADIAN (180 / 3.14159265358979323846) #define RADIANS_PER_DEGREE (1 / DEGREES_PER_RADIAN) -#define LAB_EPSILON (216.0 / 24389.0) -#define LAB_KAPPA (24389.0 / 27.0) +#define LAB_EPSILON (216.0f / 24389.0f) +#define LAB_KAPPA (24389.0f / 27.0f) /* The constants below hard-code the D50-adapted sRGB ICC profile * reference white, aka the ICC profile D50 illuminant. @@ -46,9 +46,9 @@ * hard-coded D50 ICC profile illuminant values: */ -#define D50_WHITE_REF_X 0.964202880 -#define D50_WHITE_REF_Y 1.000000000 -#define D50_WHITE_REF_Z 0.824905400 +#define D50_WHITE_REF_X 0.964202880f +#define D50_WHITE_REF_Y 1.000000000f +#define D50_WHITE_REF_Z 0.824905400f int init (void); @@ -444,6 +444,63 @@ cubef (float f) return f * f * f; } +/* origin: FreeBSD /usr/src/lib/msun/src/s_cbrtf.c */ +/* + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + * Debugged and optimized by Bruce D. Evans. + */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ +/* _cbrtf(x) + * Return cube root of x + */ + +#include +#include + +static const unsigned +B1 = 709958130, /* B1 = (127-127.0/3-0.03306235651)*2**23 */ +B2 = 642849266; /* B2 = (127-127.0/3-24/3-0.03306235651)*2**23 */ + +static inline float _cbrtf(float x) +{ + float r,T; + union {float f; uint32_t i;} u = {x}; + uint32_t hx = u.i & 0x7fffffff; + + if (hx >= 0x7f800000) /* cbrt(NaN,INF) is itself */ + return x + x; + + /* rough cbrt to 5 bits */ + if (hx < 0x00800000) { /* zero or subnormal? */ + if (hx == 0) + return x; /* cbrt(+-0) is itself */ + u.f = x*0x1p24f; + hx = u.i & 0x7fffffff; + hx = hx/3 + B2; + } else + hx = hx/3 + B1; + u.i &= 0x80000000; + u.i |= hx; + + T = u.f; + r = T*T*T; + T = T*((float)x+x+r)/(x+r+r); + + r = T*T*T; + T = T*((float)x+x+r)/(x+r+r); + + return T; +} + static long Yaf_to_Laf (float *src, float *dst, @@ -455,7 +512,7 @@ Yaf_to_Laf (float *src, { float yr = src[0]; float a = src[1]; - float L = yr > LAB_EPSILON ? 116.0 * cbrtf (yr) - 16 : LAB_KAPPA * yr; + float L = yr > LAB_EPSILON ? 116.0f * _cbrtf (yr) - 16 : LAB_KAPPA * yr; dst[0] = L; dst[1] = a; @@ -467,6 +524,7 @@ Yaf_to_Laf (float *src, return samples; } + static long rgbf_to_Labf (float *src, float *dst, @@ -484,9 +542,9 @@ rgbf_to_Labf (float *src, float yr = 0.22248840f / D50_WHITE_REF_Y * r + 0.71690369f / D50_WHITE_REF_Y * g + 0.06060791f / D50_WHITE_REF_Y * b; float zr = 0.01391602f / D50_WHITE_REF_Z * r + 0.09706116f / D50_WHITE_REF_Z * g + 0.71392822f / D50_WHITE_REF_Z * b; - float fx = xr > LAB_EPSILON ? cbrtf (xr) : (LAB_KAPPA * xr + 16.0f) / 116.0f; - float fy = yr > LAB_EPSILON ? cbrtf (yr) : (LAB_KAPPA * yr + 16.0f) / 116.0f; - float fz = zr > LAB_EPSILON ? cbrtf (zr) : (LAB_KAPPA * zr + 16.0f) / 116.0f; + float fx = xr > LAB_EPSILON ? _cbrtf (xr) : (LAB_KAPPA * xr + 16.0f) / 116.0f; + float fy = yr > LAB_EPSILON ? _cbrtf (yr) : (LAB_KAPPA * yr + 16.0f) / 116.0f; + float fz = zr > LAB_EPSILON ? _cbrtf (zr) : (LAB_KAPPA * zr + 16.0f) / 116.0f; float L = 116.0f * fy - 16.0f; float A = 500.0f * (fx - fy); @@ -521,9 +579,9 @@ rgbaf_to_Labaf (float *src, float yr = 0.22248840f / D50_WHITE_REF_Y * r + 0.71690369f / D50_WHITE_REF_Y * g + 0.06060791f / D50_WHITE_REF_Y * b; float zr = 0.01391602f / D50_WHITE_REF_Z * r + 0.09706116f / D50_WHITE_REF_Z * g + 0.71392822f / D50_WHITE_REF_Z * b; - float fx = xr > LAB_EPSILON ? cbrtf (xr) : (LAB_KAPPA * xr + 16.0f) / 116.0f; - float fy = yr > LAB_EPSILON ? cbrtf (yr) : (LAB_KAPPA * yr + 16.0f) / 116.0f; - float fz = zr > LAB_EPSILON ? cbrtf (zr) : (LAB_KAPPA * zr + 16.0f) / 116.0f; + float fx = xr > LAB_EPSILON ? _cbrtf (xr) : (LAB_KAPPA * xr + 16.0f) / 116.0f; + float fy = yr > LAB_EPSILON ? _cbrtf (yr) : (LAB_KAPPA * yr + 16.0f) / 116.0f; + float fz = zr > LAB_EPSILON ? _cbrtf (zr) : (LAB_KAPPA * zr + 16.0f) / 116.0f; float L = 116.0f * fy - 16.0f; float A = 500.0f * (fx - fy); @@ -1044,7 +1102,6 @@ types_u16 (void) babl_type_new ( "CIE u16 ab", - "id", "CIE u8 ab", "integer", "unsigned", "bits", 16, diff --git a/extensions/Makefile.am b/extensions/Makefile.am index 0aeb9b7..923ddad 100644 --- a/extensions/Makefile.am +++ b/extensions/Makefile.am @@ -15,6 +15,7 @@ AM_CPPFLAGS = \ extdir = $(libdir)/babl-@BABL_API_VERSION@ ext_LTLIBRARIES = \ + 16bit.la \ cairo.la \ CIE.la \ float-half.la \ diff --git a/extensions/Makefile.in b/extensions/Makefile.in index 48926ce..a696fd6 100644 --- a/extensions/Makefile.in +++ b/extensions/Makefile.in @@ -133,13 +133,16 @@ am__uninstall_files_from_dir = { \ } am__installdirs = "$(DESTDIR)$(extdir)" LTLIBRARIES = $(ext_LTLIBRARIES) -CIE_la_LIBADD = -am_CIE_la_OBJECTS = CIE.lo -CIE_la_OBJECTS = $(am_CIE_la_OBJECTS) +16bit_la_LIBADD = +16bit_la_SOURCES = 16bit.c +16bit_la_OBJECTS = 16bit.lo AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = +CIE_la_LIBADD = +am_CIE_la_OBJECTS = CIE.lo +CIE_la_OBJECTS = $(am_CIE_la_OBJECTS) HSL_la_LIBADD = am_HSL_la_OBJECTS = HSL.lo HSL_la_OBJECTS = $(am_HSL_la_OBJECTS) @@ -255,8 +258,8 @@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = -SOURCES = $(CIE_la_SOURCES) $(HSL_la_SOURCES) $(HSV_la_SOURCES) \ - $(cairo_la_SOURCES) $(fast_float_la_SOURCES) \ +SOURCES = 16bit.c $(CIE_la_SOURCES) $(HSL_la_SOURCES) \ + $(HSV_la_SOURCES) $(cairo_la_SOURCES) $(fast_float_la_SOURCES) \ $(float_half_la_SOURCES) $(float_la_SOURCES) \ $(gegl_fixups_la_SOURCES) $(gggl_lies_la_SOURCES) \ $(gggl_table_lies_la_SOURCES) $(gggl_table_la_SOURCES) \ @@ -266,8 +269,8 @@ SOURCES = $(CIE_la_SOURCES) $(HSL_la_SOURCES) $(HSV_la_SOURCES) \ $(sse2_int16_la_SOURCES) $(sse2_int8_la_SOURCES) \ $(sse4_int8_la_SOURCES) $(two_table_la_SOURCES) \ $(ycbcr_la_SOURCES) -DIST_SOURCES = $(CIE_la_SOURCES) $(HSL_la_SOURCES) $(HSV_la_SOURCES) \ - $(cairo_la_SOURCES) $(fast_float_la_SOURCES) \ +DIST_SOURCES = 16bit.c $(CIE_la_SOURCES) $(HSL_la_SOURCES) \ + $(HSV_la_SOURCES) $(cairo_la_SOURCES) $(fast_float_la_SOURCES) \ $(float_half_la_SOURCES) $(float_la_SOURCES) \ $(gegl_fixups_la_SOURCES) $(gggl_lies_la_SOURCES) \ $(gggl_table_lies_la_SOURCES) $(gggl_table_la_SOURCES) \ @@ -466,6 +469,7 @@ AM_CPPFLAGS = \ extdir = $(libdir)/babl-@BABL_API_VERSION@ ext_LTLIBRARIES = \ + 16bit.la \ cairo.la \ CIE.la \ float-half.la \ @@ -587,6 +591,9 @@ clean-extLTLIBRARIES: rm -f $${locs}; \ } +16bit.la: $(16bit_la_OBJECTS) $(16bit_la_DEPENDENCIES) $(EXTRA_16bit_la_DEPENDENCIES) + $(AM_V_CCLD)$(LINK) -rpath $(extdir) $(16bit_la_OBJECTS) $(16bit_la_LIBADD) $(LIBS) + CIE.la: $(CIE_la_OBJECTS) $(CIE_la_DEPENDENCIES) $(EXTRA_CIE_la_DEPENDENCIES) $(AM_V_CCLD)$(LINK) -rpath $(extdir) $(CIE_la_OBJECTS) $(CIE_la_LIBADD) $(LIBS) @@ -662,6 +669,7 @@ mostlyclean-compile: distclean-compile: -rm -f *.tab.c +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/16bit.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CIE.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HSL.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HSV.Plo@am__quote@ diff --git a/extensions/cairo.c b/extensions/cairo.c index 56413a2..5569ab6 100644 --- a/extensions/cairo.c +++ b/extensions/cairo.c @@ -29,16 +29,17 @@ static inline long conv_rgba8_cairo24_le (unsigned char *src, unsigned char *dst, long samples) { long n = samples; + uint32_t *srci = (void *)src; + uint32_t *dsti = (void *)dst; + while (n--) { - unsigned char red = *src++; - unsigned char green = *src++; - unsigned char blue = *src++; - *dst++ = blue; - *dst++ = green; - *dst++ = red; - *dst++ = 255; - src++; + uint32_t orig = *srci++; + uint32_t green_alpha = (orig & 0x0000ff00); + uint32_t red_blue = (orig & 0x00ff00ff); + uint32_t red = red_blue << 16; + uint32_t blue = red_blue >> 16; + *dsti++ = green_alpha | red | blue | 0xff000000; } return samples; } @@ -58,8 +59,11 @@ conv_rgb8_cairo24_le (unsigned char *src, unsigned char *dst, long samples) *dst++ = 255; } return samples; + + } +#if 0 static inline long conv_rgbA8_premul_cairo32_le (unsigned char *src, unsigned char *dst, long samples) { @@ -78,6 +82,28 @@ conv_rgbA8_premul_cairo32_le (unsigned char *src, unsigned char *dst, long sampl } return samples; } +#else + +static inline long +conv_rgbA8_premul_cairo32_le (unsigned char *src, unsigned char *dst, long samples) +{ + long n = samples; + uint32_t *srci = (void *)src; + uint32_t *dsti = (void *)dst; + + while (n--) + { + uint32_t orig = *srci++; + uint32_t green_alpha = (orig & 0xff00ff00); + uint32_t red_blue = (orig & 0x00ff00ff); + uint32_t red = red_blue << 16; + uint32_t blue = red_blue >> 16; + *dsti++ = green_alpha | red | blue; + } + return samples; +} +#endif + static inline long conv_rgbA8_cairo32_le (unsigned char *src, unsigned char *dst, long samples) @@ -94,12 +120,128 @@ conv_rgbA8_cairo32_le (unsigned char *src, unsigned char *dst, long samples) *dst++ = div_255 (blue * alpha); *dst++ = div_255 (green * alpha); *dst++ = div_255 (red * alpha); + *dst++ = alpha; + } + return samples; +} + +static inline long +conv_rgb8_cairo32_le (unsigned char *src, unsigned char *dst, long samples) +{ + long n = samples; + while (n--) + { + unsigned char red = *src++; + unsigned char green = *src++; + unsigned char blue = *src++; + + *dst++ = blue; + *dst++ = green; + *dst++ = red; + *dst++ = 0xff; + } + return samples; +} + + + + +static inline long +conv_yA8_cairo32_le (unsigned char *src, unsigned char *dst, long samples) +{ + long n = samples; + while (n--) + { + unsigned char gray = *src++; + unsigned char alpha = *src++; + unsigned char val = div_255 (gray * alpha); + #undef div_255 + + *dst++ = val; + *dst++ = val; + *dst++ = val; *dst++ = alpha; } return samples; } +static inline long +conv_yA16_cairo32_le (unsigned char *src, unsigned char *dst, long samples) +{ + long n = samples; + uint16_t *ssrc = (void*) src; + while (n--) + { + float alpha = (ssrc[1]) / 65535.0f; + int val = (ssrc[0] * alpha) * (0xff / 65535.0f ) + 0.5f; + *dst++ = val; + *dst++ = val; + *dst++ = val; + *dst++ = (alpha * 0xff + 0.5f); + ssrc+=2; + } + return samples; +} + +static inline long +conv_y8_cairo32_le (unsigned char *src, unsigned char *dst, long samples) +{ + long n = samples; + while (n--) + { + unsigned char val = *src++; + *dst++ = val; + *dst++ = val; + *dst++ = val; + *dst++ = 0xff; + } + return samples; +} + +static inline long +conv_y16_cairo32_le (unsigned char *src, unsigned char *dst, long samples) +{ + long n = samples; + uint16_t *s16 = (void*)src; + while (n--) + { +#define div_257(a) ((((a)+128)-(((a)+128)>>8))>>8) + uint16_t v16 = *s16++; + unsigned char val = div_257(v16); +#undef dib_257 + *dst++ = val; + *dst++ = val; + *dst++ = val; + *dst++ = 0xff; + } + return samples; +} + +static long +conv_rgbA_gamma_float_cairo32_le (unsigned char *src, + unsigned char *dst, + long samples) +{ + float *fsrc = (float *) src; + unsigned char *cdst = (unsigned char *) dst; + int n = samples; + + while (n--) + { + int val = fsrc[2] * 255.0f + 0.5f; + *cdst++ = val >= 0xff ? 0xff : val <= 0 ? 0 : val; + val = fsrc[1] * 255.0f + 0.5f; + *cdst++ = val >= 0xff ? 0xff : val <= 0 ? 0 : val; + val = fsrc[0] * 255.0f + 0.5f; + *cdst++ = val >= 0xff ? 0xff : val <= 0 ? 0 : val; + val = fsrc[3] * 255.0f + 0.5f; + *cdst++ = val >= 0xff ? 0xff : val <= 0 ? 0 : val; + fsrc+=4; + } + return samples; +} + static long conv_rgbafloat_cairo32_le (unsigned char *src, unsigned char *dst, @@ -145,6 +287,48 @@ conv_rgbafloat_cairo32_le (unsigned char *src, return samples; } + +static long +conv_yafloat_cairo32_le (unsigned char *src, + unsigned char *dst, + long samples) +{ + float *fsrc = (float *) src; + unsigned char *cdst = (unsigned char *) dst; + int n = samples; + + while (n--) + { + float gray = *fsrc++; + float alpha = *fsrc++; + if (alpha >= 1.0) + { + int val = babl_linear_to_gamma_2_2f (gray) * 0xff + 0.5f; + val = val >= 0xff ? 0xff : val <= 0 ? 0 : val; + *cdst++ = val; + *cdst++ = val; + *cdst++ = val; + *cdst++ = 0xff; + } + else if (alpha <= 0.0) + { + (*(uint32_t*)cdst)=0; + cdst+=4; + } + else + { + float balpha = alpha * 0xff; + int val = babl_linear_to_gamma_2_2f (gray) * balpha + 0.5f; + val = val >= 0xff ? 0xff : val <= 0 ? 0 : val; + *cdst++ = val; + *cdst++ = val; + *cdst++ = val; + *cdst++ = balpha + 0.5f; + } + } + return samples; +} + int init (void) { @@ -175,14 +359,34 @@ init (void) babl_component ("PAD"), NULL ); - babl_conversion_new (babl_format ("R'aG'aB'aA u8"), f32, "linear", conv_rgbA8_premul_cairo32_le, NULL); + babl_conversion_new (babl_format ("R'G'B'A u8"), f32, "linear", conv_rgbA8_cairo32_le, NULL); + + babl_conversion_new (babl_format ("R'G'B' u8"), f32, "linear", + conv_rgb8_cairo32_le, NULL); + + babl_conversion_new (babl_format ("Y'A u8"), f32, "linear", + conv_yA8_cairo32_le, NULL); + babl_conversion_new (babl_format ("Y'A u16"), f32, "linear", + conv_yA16_cairo32_le, NULL); + + + babl_conversion_new (babl_format ("Y' u8"), f32, "linear", + conv_y8_cairo32_le, NULL); + babl_conversion_new (babl_format ("Y' u16"), f32, "linear", + conv_y16_cairo32_le, NULL); + babl_conversion_new (babl_format ("RGBA float"), f32, "linear", conv_rgbafloat_cairo32_le, NULL); + babl_conversion_new (babl_format ("YA float"), f32, "linear", + conv_yafloat_cairo32_le, NULL); + + babl_conversion_new (babl_format ("R'aG'aB'aA float"), f32, "linear", + conv_rgbA_gamma_float_cairo32_le, NULL); babl_conversion_new (babl_format ("R'G'B'A u8"), f24, "linear", conv_rgba8_cairo24_le, NULL); @@ -211,6 +415,8 @@ init (void) babl_component ("B'"), NULL ); + + /* formats are registered - but no fast paths, this will be slow */ } babl_format_new ( "name", "cairo-A8", diff --git a/extensions/fast-float.c b/extensions/fast-float.c index 162b3f5..163ffe8 100644 --- a/extensions/fast-float.c +++ b/extensions/fast-float.c @@ -411,6 +411,47 @@ conv_rgbaF_linear_rgbA8_gamma (unsigned char *src, return samples; } +static INLINE long +conv_yaF_linear_rgbA8_gamma (unsigned char *src, + unsigned char *dst, + long samples) +{ + float *fsrc = (float *) src; + uint8_t *cdst = (uint8_t *) dst; + int n = samples; + + while (n--) + { + float gray = *fsrc++; + float alpha = *fsrc++; + if (alpha >= 1.0) + { + int val = linear_to_gamma_2_2_lut (gray) * 0xff + 0.5f; + *cdst++ = val >= 0xff ? 0xff : val <= 0 ? 0 : val; + *cdst++ = val >= 0xff ? 0xff : val <= 0 ? 0 : val; + *cdst++ = val >= 0xff ? 0xff : val <= 0 ? 0 : val; + *cdst++ = 0xff; + } + else if (alpha <= 0.0) + { + *((uint32_t*)(cdst))=0; + cdst+=4; + } + else + { + float balpha = alpha * 0xff; + int val = linear_to_gamma_2_2_lut (gray) * balpha + 0.5f; + *cdst++ = val >= 0xff ? 0xff : val <= 0 ? 0 : val; + *cdst++ = val >= 0xff ? 0xff : val <= 0 ? 0 : val; + *cdst++ = val >= 0xff ? 0xff : val <= 0 ? 0 : val; + *cdst++ = balpha + 0.5f; + } + } + return samples; +} + + + static long conv_rgbaF_linear_rgbA8_gamma_cairo (unsigned char *src, unsigned char *dst, @@ -580,6 +621,13 @@ int init (void); int init (void) { + const Babl *yaF_linear = babl_format_new ( + babl_model ("YA"), + babl_type ("float"), + babl_component ("Y"), + babl_component ("A"), + NULL); + const Babl *rgbaF_linear = babl_format_new ( babl_model ("RGBA"), babl_type ("float"), @@ -646,6 +694,8 @@ init (void) babl_component ("B'"), NULL); + return 0; // XXX: the fast paths registered here doesn't correctly + // clamp negative values - disabling for now { float f; float a; @@ -689,7 +739,7 @@ init (void) o (rgbaF_gamma, rgbaF_linear); o (rgbF_linear, rgbF_gamma); o (rgbF_gamma, rgbF_linear); - + o (yaF_linear, rgbA8_gamma); return 0; } diff --git a/extensions/gggl-lies.c b/extensions/gggl-lies.c index 5d50f5b..3d1627f 100644 --- a/extensions/gggl-lies.c +++ b/extensions/gggl-lies.c @@ -250,7 +250,7 @@ conv_gaF_ga16 (unsigned char *src, unsigned char *dst, long samples) } #define conv_rgbAF_rgbAD conv_rgbaF_rgbaD -#define conv_rgbAD_rgbAD conv_rgbaD_rgbaF +#define conv_rgbAD_rgbAF conv_rgbaD_rgbaF #define conv_rgbAF_rgbA16 conv_rgbaF_rgba16 #define conv_gF_g16 conv_F_16 #define conv_gAF_gA16 conv_gaF_ga16 @@ -418,6 +418,29 @@ conv_rgbaF_rgbF (unsigned char *src, unsigned char *dst, long samples) return samples; } + +static long +conv_gF_rgbaF (unsigned char *src, unsigned char *dst, long samples) +{ + long n = samples; + + while (n--) + { + *(int *) dst = (*(int *) src); + dst += 4; + *(int *) dst = (*(int *) src); + dst += 4; + *(int *) dst = (*(int *) src); + dst += 4; + *(float *) dst = 1.0; + dst += 4; + src += 4; + } + return samples; +} + +#define conv_gF_rgbAF conv_gF_rgbaF + static long conv_rgbF_rgbaF (unsigned char *src, unsigned char *dst, long samples) { @@ -725,6 +748,15 @@ init (void) babl_component ("Ba"), babl_component ("A"), NULL); + const Babl *rgbAD = babl_format_new ( + babl_model ("RaGaBaA"), + babl_type ("double"), + babl_component ("Ra"), + babl_component ("Ga"), + babl_component ("Ba"), + babl_component ("A"), + NULL); + const Babl *rgbA16 = babl_format_new ( babl_model ("RaGaBaA"), babl_type ("u16"), @@ -819,6 +851,8 @@ init (void) o (rgbaF, rgbaD); o (rgbaD, rgbaF); + o (rgbAF, rgbAD); + o (rgbAD, rgbAF); o (rgbaF, rgba8); o (rgba8, rgbaF); o (rgbaF, rgba16); @@ -840,6 +874,8 @@ init (void) o (gaF, ga8); o (gAF, gA8); o (gF, g8); + o (gF, rgbAF); + o (gF, rgbaF); o (ga8, gaF); o (gA8, gAF); o (g8, gF); diff --git a/extensions/gggl.c b/extensions/gggl.c index c4b8ce4..b01659f 100644 --- a/extensions/gggl.c +++ b/extensions/gggl.c @@ -607,6 +607,28 @@ conv_rgbA16_rgbaF (unsigned char *src, unsigned char *dst, long samples) return samples; } +static long +conv_gF_rgbaF (unsigned char *src, unsigned char *dst, long samples) +{ + long n = samples; + + while (n--) + { + *(int *) dst = (*(int *) src); + dst += 4; + *(int *) dst = (*(int *) src); + dst += 4; + *(int *) dst = (*(int *) src); + dst += 4; + *(float *) dst = 1.0; + dst += 4; + src += 4; + } + return samples; +} + +#define conv_gF_rgbAF conv_gF_rgbaF + /* static long conv_rgb8_rgbaF (unsigned char *src, @@ -1102,6 +1124,8 @@ init (void) o (gF, gaF); o (gF, gAF); o (gF, rgbF); + o (gF, rgbaF); + o (gF, rgbAF); o (gaF, rgbaF); o (gAF, rgbAF); o (rgbaF, rgb8); diff --git a/extensions/gimp-8bit.c b/extensions/gimp-8bit.c index d3e9522..55bd95c 100644 --- a/extensions/gimp-8bit.c +++ b/extensions/gimp-8bit.c @@ -228,6 +228,24 @@ conv_ga8_gamma_2_2_gaF_linear (unsigned char *src, return samples; } +static INLINE long +conv_ga8_gamma_2_2_rgba8_gamma_2_2 (unsigned char *src, + unsigned char *dst, + long samples) +{ + long n = samples; + + while (n--) + { + *dst++ = *src; + *dst++ = *src; + *dst++ = *src++; + *dst++ = *src++; + } + + return samples; +} + static INLINE long conv_ga8_linear_rgbaF_linear (unsigned char *src, unsigned char *dst, @@ -496,6 +514,8 @@ init (void) o (ga8_linear, rgbaF_linear); o (ga8_gamma_2_2, rgbaF_linear); + o (ga8_gamma_2_2, rgba8_gamma_2_2); + o (g8_linear, gF_linear); o (g8_gamma_2_2, gF_linear); o (g8_linear, rgbaF_linear); diff --git a/extensions/simple.c b/extensions/simple.c index bde7785..1430ab1 100644 --- a/extensions/simple.c +++ b/extensions/simple.c @@ -4,29 +4,42 @@ int init (void); + static inline long -float_to_u8 (unsigned char *src_char, unsigned char *dst, long samples) +float_to_u8_x1 (unsigned char *src_char, unsigned char *dst, long samples) { float *src = (float *)src_char; long n = samples; while (n--) { float r = src[0]; - float g = src[1]; - float b = src[2]; - float a = src[3]; - dst[0] = (r >= 1.0f) ? 0xFF : ((r <= 0.0f) ? 0x0 : 0xFF * r + 0.5f); - dst[1] = (g >= 1.0f) ? 0xFF : ((g <= 0.0f) ? 0x0 : 0xFF * g + 0.5f); - dst[2] = (b >= 1.0f) ? 0xFF : ((b <= 0.0f) ? 0x0 : 0xFF * b + 0.5f); - dst[3] = (a >= 1.0f) ? 0xFF : ((a <= 0.0f) ? 0x0 : 0xFF * a + 0.5f); - - dst += 4; - src += 4; + dst += 1; + src += 1; } return samples; } +static inline long +float_to_u8_x4 (unsigned char *src_char, unsigned char *dst, long samples) +{ + return float_to_u8_x1 (src_char, dst, samples * 4); +} + +static inline long +float_to_u8_x3 (unsigned char *src_char, unsigned char *dst, long samples) +{ + return float_to_u8_x1 (src_char, dst, samples * 3); +} + +static inline long +float_to_u8_x2 (unsigned char *src_char, unsigned char *dst, long samples) +{ + return float_to_u8_x1 (src_char, dst, samples * 2); +} + + + static inline long float_pre_to_u8_pre (unsigned char *src_char, unsigned char *dst, long samples) { @@ -59,18 +72,56 @@ float_pre_to_u8_pre (unsigned char *src_char, unsigned char *dst, long samples) } static inline long -float_to_u16 (unsigned char *src_char, unsigned char *dst_char, long samples) +float_to_u16_x1 (unsigned char *src_char, unsigned char *dst_char, long samples) { float *src = (float *)src_char; uint16_t *dst = (uint16_t *)dst_char; long n = samples; + while (n--) + { + float r = src[0]; + dst[0] = (r >= 1.0f) ? 0xFFFF : ((r <= 0.0f) ? 0x0 : 0xFFFF * r + 0.5f); + dst += 1; + src += 1; + } + return samples; +} +static inline long +float_to_u16_x2 (unsigned char *src_char, unsigned char *dst_char, long samples) +{ + return float_to_u16_x1 (src_char, dst_char, samples * 2); +} +static inline long +float_to_u16_x3 (unsigned char *src_char, unsigned char *dst_char, long samples) +{ + return float_to_u16_x1 (src_char, dst_char, samples * 3); +} +static inline long +float_to_u16_x4 (unsigned char *src_char, unsigned char *dst_char, long samples) +{ + return float_to_u16_x1 (src_char, dst_char, samples * 4); +} + +static inline long +float_pre_to_u16_pre (unsigned char *src_char, unsigned char *dst_char, long samples) +{ + float *src = (float *)src_char; + uint16_t *dst = (uint16_t *)dst_char; + long n = samples; while (n--) { float r = src[0]; float g = src[1]; float b = src[2]; float a = src[3]; - + + if (a > 1.0f) { + r /= a; + g /= a; + b /= a; + a /= a; + } + dst[0] = (r >= 1.0f) ? 0xFFFF : ((r <= 0.0f) ? 0x0 : 0xFFFF * r + 0.5f); dst[1] = (g >= 1.0f) ? 0xFFFF : ((g <= 0.0f) ? 0x0 : 0xFFFF * g + 0.5f); dst[2] = (b >= 1.0f) ? 0xFFFF : ((b <= 0.0f) ? 0x0 : 0xFFFF * b + 0.5f); @@ -83,10 +134,10 @@ float_to_u16 (unsigned char *src_char, unsigned char *dst_char, long samples) } static inline long -float_pre_to_u16_pre (unsigned char *src_char, unsigned char *dst_char, long samples) +float_pre_to_u32_pre (unsigned char *src_char, unsigned char *dst_char, long samples) { float *src = (float *)src_char; - uint16_t *dst = (uint16_t *)dst_char; + uint32_t *dst = (uint32_t *)dst_char; long n = samples; while (n--) { @@ -102,10 +153,10 @@ float_pre_to_u16_pre (unsigned char *src_char, unsigned char *dst_char, long sam a /= a; } - dst[0] = (r >= 1.0f) ? 0xFFFF : ((r <= 0.0f) ? 0x0 : 0xFFFF * r + 0.5f); - dst[1] = (g >= 1.0f) ? 0xFFFF : ((g <= 0.0f) ? 0x0 : 0xFFFF * g + 0.5f); - dst[2] = (b >= 1.0f) ? 0xFFFF : ((b <= 0.0f) ? 0x0 : 0xFFFF * b + 0.5f); - dst[3] = (a >= 1.0f) ? 0xFFFF : ((a <= 0.0f) ? 0x0 : 0xFFFF * a + 0.5f); + dst[0] = (r >= 1.0f) ? 0xFFFFFFFF : ((r <= 0.0f) ? 0x0 : 0xFFFFFFFF * r + 0.5f); + dst[1] = (g >= 1.0f) ? 0xFFFFFFFF : ((g <= 0.0f) ? 0x0 : 0xFFFFFFFF * g + 0.5f); + dst[2] = (b >= 1.0f) ? 0xFFFFFFFF : ((b <= 0.0f) ? 0x0 : 0xFFFFFFFF * b + 0.5f); + dst[3] = (a >= 1.0f) ? 0xFFFFFFFF : ((a <= 0.0f) ? 0x0 : 0xFFFFFFFF * a + 0.5f); dst += 4; src += 4; @@ -113,6 +164,135 @@ float_pre_to_u16_pre (unsigned char *src_char, unsigned char *dst_char, long sam return samples; } + +static inline long +float_to_u32_x1 (unsigned char *src_char, unsigned char *dst_char, long samples) +{ + float *src = (float *)src_char; + uint32_t *dst = (uint32_t *)dst_char; + long n = samples; + while (n--) + { + float r = src[0]; + + dst[0] = (r >= 1.0f) ? 0xFFFFFFFF : ((r <= 0.0f) ? 0x0 : 0xFFFFFFFF * r + 0.5f); + + dst += 1; + src += 1; + } + return samples; +} +static inline long +float_to_u32_x2 (unsigned char *src_char, unsigned char *dst_char, long samples) +{ + return float_to_u32_x1 (src_char, dst_char, samples * 2); +} +static inline long +float_to_u32_x3 (unsigned char *src_char, unsigned char *dst_char, long samples) +{ + return float_to_u32_x1 (src_char, dst_char, samples * 3); +} +static inline long +float_to_u32_x4 (unsigned char *src_char, unsigned char *dst_char, long samples) +{ + return float_to_u32_x1 (src_char, dst_char, samples * 4); +} + + +static inline long +u32_to_float (unsigned char *src_char, unsigned char *dst_char, long samples) +{ + uint32_t *src = (uint32_t *)src_char; + float *dst = (float *)dst_char; + long n = samples; + while (n--) + { + dst[0] = src[0] / 4294967295.0f; + dst ++; + src ++; + } + return samples; +} + +static inline long +u32_to_float_x4 (unsigned char *src_char, unsigned char *dst_char, long samples) +{ + u32_to_float (src_char, dst_char, samples * 4); + return samples; +} + +static inline long +u32_to_float_x3 (unsigned char *src_char, unsigned char *dst_char, long samples) +{ + u32_to_float (src_char, dst_char, samples * 3); + return samples; +} + + +static inline long +u32_to_float_x2 (unsigned char *src_char, unsigned char *dst_char, long samples) +{ + u32_to_float (src_char, dst_char, samples * 2); + return samples; +} + + +static inline long +u16_to_float (unsigned char *src_char, unsigned char *dst_char, long samples) +{ + uint16_t *src = (uint16_t *)src_char; + float *dst = (float *)dst_char; + long n = samples; + while (n--) + { + dst[0] = src[0] / 65535.0f; + dst ++; + src ++; + } + return samples; +} + +static inline long +u16_to_float_x4 (unsigned char *src_char, unsigned char *dst_char, long samples) +{ + u16_to_float (src_char, dst_char, samples * 4); + return samples; +} + +static inline long +u16_to_float_x3 (unsigned char *src_char, unsigned char *dst_char, long samples) +{ + u16_to_float (src_char, dst_char, samples * 3); + return samples; +} + + +static inline long +u16_to_float_x2 (unsigned char *src_char, unsigned char *dst_char, long samples) +{ + u16_to_float (src_char, dst_char, samples * 2); + return samples; +} + +static inline long +yau16_rgbaf (unsigned char *src_char, unsigned char *dst_char, long samples) +{ + uint16_t *src = (uint16_t *)src_char; + float *dst = (float *)dst_char; + long n = samples; + while (n--) + { + dst[0] = src[0] / 65535.0f; + dst[1] = src[0] / 65535.0f; + dst[2] = src[0] / 65535.0f; + dst[3] = src[1] / 65535.0f; + dst +=4; + src +=2; + } + return samples; +} + + int init (void) { @@ -120,12 +300,42 @@ init (void) babl_conversion_new (babl_format ("R'G'B'A float"), babl_format ("R'G'B'A u8"), "linear", - float_to_u8, + float_to_u8_x4, NULL); babl_conversion_new (babl_format ("RGBA float"), babl_format ("RGBA u8"), "linear", - float_to_u8, + float_to_u8_x4, + NULL); + babl_conversion_new (babl_format ("R'G'B' float"), + babl_format ("R'G'B' u8"), + "linear", + float_to_u8_x3, + NULL); + babl_conversion_new (babl_format ("RGB float"), + babl_format ("RGB u8"), + "linear", + float_to_u8_x3, + NULL); + babl_conversion_new (babl_format ("Y'A float"), + babl_format ("Y'A u8"), + "linear", + float_to_u8_x2, + NULL); + babl_conversion_new (babl_format ("YA float"), + babl_format ("YA u8"), + "linear", + float_to_u8_x2, + NULL); + babl_conversion_new (babl_format ("YA float"), + babl_format ("YA u8"), + "linear", + float_to_u8_x2, + NULL); + babl_conversion_new (babl_format ("Y' float"), + babl_format ("Y' u8"), + "linear", + float_to_u8_x1, NULL); babl_conversion_new (babl_format ("R'aG'aB'aA float"), babl_format ("R'aG'aB'aA u8"), @@ -142,12 +352,43 @@ init (void) babl_conversion_new (babl_format ("R'G'B'A float"), babl_format ("R'G'B'A u16"), "linear", - float_to_u16, + float_to_u16_x4, NULL); babl_conversion_new (babl_format ("RGBA float"), babl_format ("RGBA u16"), "linear", - float_to_u16, + float_to_u16_x4, + NULL); + + babl_conversion_new (babl_format ("R'G'B' float"), + babl_format ("R'G'B' u16"), + "linear", + float_to_u16_x3, + NULL); + babl_conversion_new (babl_format ("RGB float"), + babl_format ("RGB u16"), + "linear", + float_to_u16_x3, + NULL); + babl_conversion_new (babl_format ("Y'A float"), + babl_format ("Y'A u16"), + "linear", + float_to_u16_x2, + NULL); + babl_conversion_new (babl_format ("YA float"), + babl_format ("YA u16"), + "linear", + float_to_u16_x2, + NULL); + babl_conversion_new (babl_format ("Y' float"), + babl_format ("Y' u16"), + "linear", + float_to_u16_x1, + NULL); + babl_conversion_new (babl_format ("Y float"), + babl_format ("Y u16"), + "linear", + float_to_u16_x1, NULL); babl_conversion_new (babl_format ("R'aG'aB'aA float"), babl_format ("R'aG'aB'aA u16"), @@ -160,5 +401,147 @@ init (void) float_pre_to_u16_pre, NULL); + + /* float and u32 */ + babl_conversion_new (babl_format ("R'G'B'A float"), + babl_format ("R'G'B'A u32"), + "linear", + float_to_u32_x4, + NULL); + babl_conversion_new (babl_format ("RGBA float"), + babl_format ("RGBA u32"), + "linear", + float_to_u32_x4, + NULL); + babl_conversion_new (babl_format ("R'G'B' float"), + babl_format ("R'G'B' u32"), + "linear", + float_to_u32_x3, + NULL); + babl_conversion_new (babl_format ("RGB float"), + babl_format ("RGB u32"), + "linear", + float_to_u32_x3, + NULL); + babl_conversion_new (babl_format ("Y'A float"), + babl_format ("Y'A u32"), + "linear", + float_to_u32_x2, + NULL); + babl_conversion_new (babl_format ("YA float"), + babl_format ("YA u32"), + "linear", + float_to_u32_x2, + NULL); + babl_conversion_new (babl_format ("Y' float"), + babl_format ("Y' u32"), + "linear", + float_to_u32_x1, + NULL); + babl_conversion_new (babl_format ("Y float"), + babl_format ("Y u32"), + "linear", + float_to_u32_x1, + NULL); + babl_conversion_new (babl_format ("R'aG'aB'aA float"), + babl_format ("R'aG'aB'aA u32"), + "linear", + float_pre_to_u32_pre, + NULL); + babl_conversion_new (babl_format ("RaGaBaA float"), + babl_format ("RaGaBaA u32"), + "linear", + float_pre_to_u32_pre, + NULL); + babl_conversion_new (babl_format ("YA u32"), + babl_format ("YA float"), + "linear", + u32_to_float_x2, + NULL); + babl_conversion_new (babl_format ("Y'A u32"), + babl_format ("Y'A float"), + "linear", + u32_to_float_x2, + NULL); + babl_conversion_new (babl_format ("Y u32"), + babl_format ("Y float"), + "linear", + u32_to_float, + NULL); + babl_conversion_new (babl_format ("Y' u32"), + babl_format ("Y' float"), + "linear", + u32_to_float, + NULL); + babl_conversion_new (babl_format ("RGBA u32"), + babl_format ("RGBA float"), + "linear", + u32_to_float_x4, + NULL); + babl_conversion_new (babl_format ("R'G'B'A u32"), + babl_format ("R'G'B'A float"), + "linear", + u32_to_float_x4, + NULL); + + babl_conversion_new (babl_format ("RGB u32"), + babl_format ("RGB float"), + "linear", + u32_to_float_x3, + NULL); + babl_conversion_new (babl_format ("R'G'B' u32"), + babl_format ("R'G'B' float"), + "linear", + u32_to_float_x3, + NULL); + + + + babl_conversion_new (babl_format ("YA u16"), + babl_format ("YA float"), + "linear", + u16_to_float_x2, + NULL); + babl_conversion_new (babl_format ("Y'A u16"), + babl_format ("Y'A float"), + "linear", + u16_to_float_x2, + NULL); + babl_conversion_new (babl_format ("Y u16"), + babl_format ("Y float"), + "linear", + u16_to_float, + NULL); + babl_conversion_new (babl_format ("Y' u16"), + babl_format ("Y' float"), + "linear", + u16_to_float, + NULL); + babl_conversion_new (babl_format ("RGBA u16"), + babl_format ("RGBA float"), + "linear", + u16_to_float_x4, + NULL); + babl_conversion_new (babl_format ("R'G'B'A u16"), + babl_format ("R'G'B'A float"), + "linear", + u16_to_float_x4, + NULL); + + babl_conversion_new (babl_format ("RGB u16"), + babl_format ("RGB float"), + "linear", + u16_to_float_x3, + NULL); + babl_conversion_new (babl_format ("R'G'B' u16"), + babl_format ("R'G'B' float"), + "linear", + u16_to_float_x3, + NULL); + babl_conversion_new (babl_format ("Y'A u16"), + babl_format ("R'G'B'A float"), + "linear", + yau16_rgbaf, + NULL); return 0; } diff --git a/extensions/sse2-float.c b/extensions/sse2-float.c index 72463ee..71fa008 100644 --- a/extensions/sse2-float.c +++ b/extensions/sse2-float.c @@ -296,7 +296,7 @@ gamma_2_2_to_linear_sse2 (__v4sf x) } #define GAMMA_RGBA(func, munge) \ -static long \ +static inline long \ func (const float *src, float *dst, long samples)\ {\ int i = samples;\ @@ -353,6 +353,14 @@ func (const float *src, float *dst, long samples)\ GAMMA_RGBA(conv_rgbaF_linear_rgbaF_gamma, linear_to_gamma_2_2_sse2) GAMMA_RGBA(conv_rgbaF_gamma_rgbaF_linear, gamma_2_2_to_linear_sse2) +static long conv_rgbaF_linear_rgbAF_gamma (const float *src, float *dst, long samples) +{ + float *tmp = alloca (sizeof(float)*4*samples); + conv_rgbaF_linear_rgbaF_gamma (src, tmp, samples); + conv_rgbaF_linear_rgbAF_linear (tmp, dst, samples); + return samples; +} + #define YA_APPLY(load, store, convert) \ { \ __v4sf yyaa0, yyaa1; \ @@ -637,6 +645,12 @@ init (void) conv_rgbaF_linear_rgbAF_linear, NULL); + babl_conversion_new(rgbaF_linear, + rgbAF_gamma, + "linear", + conv_rgbaF_linear_rgbAF_gamma, + NULL); + /* Which of these is faster varies by CPU, and the difference * is big enough that it's worthwhile to include both and * let them fight it out in the babl benchmarks. diff --git a/extensions/sse2-int8.c b/extensions/sse2-int8.c index 67ff579..5353de6 100644 --- a/extensions/sse2-int8.c +++ b/extensions/sse2-int8.c @@ -146,6 +146,12 @@ conv_rgbaF_rgba8 (const float *src, uint8_t *dst, long samples) return conv_yF_y8 (src, dst, samples * 4) / 4; } +static long +conv_rgbAF_rgbA8 (const float *src, uint8_t *dst, long samples) +{ + return conv_yF_y8 (src, dst, samples * 4) / 4; +} + #endif int init (void); @@ -154,6 +160,40 @@ int init (void) { #if defined(USE_SSE2) + + const Babl *rgbAF_linear = babl_format_new ( + babl_model ("RaGaBaA"), + babl_type ("float"), + babl_component ("Ra"), + babl_component ("Ga"), + babl_component ("Ba"), + babl_component ("A"), + NULL); + const Babl *rgbA8_linear = babl_format_new ( + babl_model ("RaGaBaA"), + babl_type ("u8"), + babl_component ("Ra"), + babl_component ("Ga"), + babl_component ("Ba"), + babl_component ("A"), + NULL); + const Babl *rgbAF_gamma = babl_format_new ( + babl_model ("R'aG'aB'aA"), + babl_type ("float"), + babl_component ("R'a"), + babl_component ("G'a"), + babl_component ("B'a"), + babl_component ("A"), + NULL); + const Babl *rgbA8_gamma = babl_format_new ( + babl_model ("R'aG'aB'aA"), + babl_type ("u8"), + babl_component ("R'a"), + babl_component ("G'a"), + babl_component ("B'a"), + babl_component ("A"), + NULL); + const Babl *rgbaF_linear = babl_format_new ( babl_model ("RGBA"), babl_type ("float"), @@ -268,6 +308,7 @@ init (void) if ((babl_cpu_accel_get_support () & BABL_CPU_ACCEL_X86_SSE2)) { CONV(rgbaF, rgba8); + CONV(rgbAF, rgbA8); CONV(rgbF, rgb8); CONV(yaF, ya8); CONV(yF, y8); diff --git a/tools/babl-verify.c b/tools/babl-verify.c index 80174db..5a1a447 100644 --- a/tools/babl-verify.c +++ b/tools/babl-verify.c @@ -1,18 +1,49 @@ #include #include -#include "babl/babl.h" +#include "../config.h" +#include "babl/babl-internal.h" int main (int argc, char **argv) { - if (argc != 3) + int final = 0; + const Babl *fish; + if (argc < 3) { fprintf (stderr, "need two args, from and to babl-formats\n"); return -1; } + if (argc == 4) + final = 1; + + if (!final) + { putenv ("BABL_DEBUG_CONVERSIONS" "=" "1"); putenv ("BABL_TOLERANCE" "=" "100000.0"); + } + babl_init (); - babl_fish (babl_format(argv[1]), babl_format (argv[2])); + + fish = babl_fish (babl_format(argv[1]), babl_format (argv[2])); + if (!fish) + return -1; + + if (final) + switch (fish->class_type) + { + case BABL_FISH: + fprintf (stderr, "%s\n", babl_get_name (fish)); + break; + case BABL_FISH_PATH: + fprintf (stderr, "chosen %s to %s: steps: %i error: %f cost: %f\n", argv[1], argv[2], fish->fish_path.conversion_list->count, fish->fish.error, fish->fish_path.cost); + for (int i = 0; i < fish->fish_path.conversion_list->count; i++) + { + fprintf (stderr, "\t%s\n", + babl_get_name(fish->fish_path.conversion_list->items[i] )); + } + break; + } + + babl_exit (); return 0; -- 2.30.2